//
//  SDWeatherView.m
//  SuperDoctor
//
//  Created by 李忠 on 7/5/16.
//  Copyright © 2016 SD. All rights reserved.
//

#import "SDWeatherView.h"

#define padding 10

@interface SDWeatherView ()

@property (nonatomic, strong) UIImageView *nightPicture;
@property (nonatomic, strong) UILabel *weather;
@property (nonatomic, strong) UIButton *currentCity;
@property (nonatomic, strong) UIView *separateVW;
@property (nonatomic, strong) UILabel *temperature;
@property (nonatomic, strong) UILabel *dateLB;

@end

@implementation SDWeatherView

- (void)setDataList:(NSArray *)dataList{
    _dataList = dataList;
    self.nightPicture.image = [UIImage imageNamed:dataList[0]];
    self.weather.text = dataList[1];
    self.temperature.text = dataList[2];
    self.dateLB.text = dataList[3];
    
    
}


- (void)layoutSubviews{
    [super layoutSubviews];
    [self setupLayout];
}
- (void)setupLayout{
    
    [self.nightPicture mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.mas_centerY);
        make.leading.mas_equalTo(padding);
        make.height.with.mas_equalTo(padding*5);
        
    }];
    [self.weather mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.mas_centerY);
        make.leading.mas_equalTo(self.nightPicture.mas_trailing).mas_offset(padding);
        
    }];
    [self.currentCity mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.mas_centerY);
        make.trailing.mas_equalTo(self.separateVW.mas_leading).mas_offset(-2*padding);
    }];
    [self.separateVW mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.top.mas_equalTo(padding);
        make.bottom.mas_equalTo(-padding);
        make.width.mas_equalTo(1);
    }];
    
    [self.temperature mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.mas_centerY).mas_offset(-padding * 0.3);
        make.leading.mas_equalTo(self.dateLB.mas_leading).mas_offset(padding);
    }];
    [self.dateLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_centerY).mas_offset(padding * 0.3);
        make.leading.mas_equalTo(self.separateVW.mas_trailing).mas_offset(2*padding);
    }];
    
}


#pragma mark
#pragma mark - 懒加载
- (UIImageView *)nightPicture{
    if (_nightPicture == nil) {
        
        _nightPicture = [[UIImageView alloc] init];
        [self addSubview:_nightPicture];
        
    }
    return _nightPicture;
}
- (UILabel *)weather{
    if (_weather == nil) {
        _weather = [[UILabel alloc] init];
        _weather.textColor = kThemeColor;
        _weather.font = FONT(15);
        [self addSubview:_weather];
    }
    return _weather;
}
- (UIButton *)currentCity{
    if (_currentCity == nil) {
        _currentCity = [UIButton buttonWithType:UIButtonTypeCustom];
        [_currentCity setTitle:@"上海" forState:UIControlStateNormal];
        
        _currentCity.titleLabel.font = FONT(15);
        [_currentCity setTitleColor:kThemeColor forState:UIControlStateNormal];
        [self addSubview:_currentCity];
    }
    return _currentCity;
}
- (UIView *)separateVW{
    if (_separateVW == nil) {
        _separateVW = [[UIView alloc] init];
        _separateVW.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:_separateVW];
    }
    return _separateVW;
}
- (UILabel *)temperature{
    if (_temperature == nil) {
        _temperature = [[UILabel alloc] init];
        _temperature.textColor = kThemeColor;
        _temperature.font = FONT(15);
        [self addSubview:_temperature];
    }
    return _temperature;
}
- (UILabel *)dateLB{
    if (_dateLB == nil) {
        _dateLB = [[UILabel alloc] init];
        _dateLB.textColor = kThemeColor;
        _dateLB.font = FONT(15);
        [self addSubview:_dateLB];
    }
    return _dateLB;
}



@end
